package com.myjavalab.reflection;

import java.lang.reflect.Method;

public class ColorUtil {

	public static void setColor(Object o){
		Class c = o.getClass();
		try{
			Method m = c.getMethod("setColor");
			m.invoke(o);
		}catch(Exception e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		UIComponent1 u1 = new UIComponent1();
		UIComponent2 u2 = new UIComponent2();
		UIComponent3 u3 = new UIComponent3();
		setColor(u1);
		setColor(u2);
		setColor(u3);
	}
}
